Skip to main content

KwikFit Invoice Generator – System Flow Overview

ViSN generates the IPP file and shares it with KwikFit. KwikFit creates the invoice JSON file from it and sends it back to ViSN. Based on this JSON file, ViSN generates the invoice and marks the enquiry as completed.


High-Level Flow

Epic References


Flow Diagram

Flow Diagram

File Formats

  • Format: Text File

  • Extension: .ath

  • The file that contains authorised enquiries.

  • Format: JSON

  • Extension: .json

  • The JSON file must contain an array of objects.

  • Each object must contain an INVOICE_HEADER property.

  • File contains authorised enquiries.


INVOICE HEADER STRUCTURE

Field Definitions

ColumnField NameTypeLengthMandatoryDescriptionExample
AACCOUNT_NOText100YesKwikFit account number mapped in ViSNM5909U
BINVOICE_NOText100YesInvoice number from IPP systemYE374831
CTAX_DATEDate10YesTax point date in DD/MM/YYYY format24/11/2025
DDEPOT_NOText100YesSupplier ID mapped to service unit in ViSN669
ECAR_REGISTRATIONText100YesVehicle Registration Mark (VRM) must match the enquiry VRMSN74USH
FINVOICE_VALUENumber(9,2)12YesTotal invoice value (Net + VAT). Format: nnnnnn.nn245.71
GVAT_TOTALNumber(9,2)12YesTotal VAT amount43.27
HORDER_NOText100YesEnquiry number in ViSN (must be numeric and exist)57294658

Test Environment Details

EnvironmentURL
Develophttps://visn-develop-branch.web.app/

Lease & Supplier User Details

ItemValue
Company NameLonnie Lind Fleet Services
Lease User CredentialsGavin.Davis.7759@digitalinnk.com
Supplier User CredentialsLois.Will.4447@digitalinnk.com

DI Admin Configuration Settings

Configuration AreaSetting
Lease > KwikFit IPP ConfigAdd the Customer Name & Mapping ID
GroupIPP Kwikfit transactions export → Enabled

Testing Procedure

Preconditions

  • Few enquiries with all job lines to Authorised status.

  • Create the JSON file based on the authorised enquiries.

  • Scheduler Links

  • kwikfit-ipp-invoice-import

    View Scheduler Job

  • generateIppInvoicingLogsCSV

    View Scheduler Job


Pre Checks

Prior to completing and generating an invoice for the enquiry in ViSN based on the IPP invoice file data, the system performs the following validations:

  1. Service Unit

    • Finds service unit within the provided account where supplierId = DEPOT_NO
    • ❌ Abort if service unit not found
  2. Enquiry

    • Finds enquiry by matching ORDER_NO (enquiryNumber) within the found service unit
    • ❌ Abort if enquiry not found
  3. VRM Validation

    • Verifies CAR_REGISTRATION matches the enquiry VRM
    • ❌ Abort if VRM mismatch
  4. Enquiry Status Check

    • Verifies enquiry is in Authorised status
    • ❌ Abort if enquiry is in an invalid status
  5. MOT Details Check

    • If enquiry contains MOT job line, verifies MOT details are completed
    • ❌ Abort if MOT details are missing
  6. ADAS Certificate Check

    • If enquiry contains ADAS calibration, verifies ADAS certificate is saved
    • ❌ Abort if ADAS certificate is missing
  7. Invoice Total Matching

    • Compares INVOICE_VALUE with ViSN calculated grand total
    • ❌ Abort if totals do not match (logs both ViSN and IPP totals)
  8. Draft Job Lines Validation

    • Checks for draft job lines on the enquiry
    • ❌ Abort if any draft job lines exist for authorised enquiries

Sample Invoice JSON File

[
{
"INVOICE_HEADER": {
"COMPANY_NO": 1,
"INVOICE_NO": "InvoiceNo-5235",
"ADVICE_NO": -1001,
"TRANSACTION_DATE": "32/13/2025",
"TAX_DATE": "09/01/2026",
"ACCOUNT_NO": "Map01",
"ACCOUNT_NAME": "Test Fleet Ltd",
"DEPOT_NO": "401",
"ORDER_NO": "5235",
"CAR_REGISTRATION": "AU49CHM",
"CAR_MILEAGE": -500,
"INVOICE_VALUE": 1327.18,
"VAT_TOTAL": 217.42
},
"LINE_ITEMS": [
{
"PART_NO": "",
"QTY_SOLD": -1,
"UNIT_PRICE": "FREE",
"LINE_VAT_RATE": 25,
"LINE_VALUE": "100.00"
}
]
}
]

Execution Steps

  1. Upload the Invoice JSON file to the Cloud Bucket.
    Path: visn-develop-imports/Kwikfit/fileDrop

  2. Set the account ID in the scheduler job and trigger it.
    Job: kwikfit-ipp-invoice-import

  3. Check the Import Manager logs:

    • [Validation Passed]
      • Queue invoice generation task.
      • Increment invoicesAddedToQueue.
    • [Validation Failed]
      • Log validation error.
      • Increment invoicesFailedValidation.
  4. Check the Queue Services:

    • Find service unit in account where supplierId = DEPOT_NO.
    • Find enquiry by ORDER_NO in service unit.
    • Validate VRM matches.
    • Validate enquiry status.
    • Validate MOT details (if applicable).
    • Validate ADAS certificate (if applicable).
    • Validate invoice total matches.
  5. [All Preconditions Passed]

    • Progress enquiry to "Completed".
    • Create invoice and progress to "Invoiced".
    • Log success and increment invoicesGenerated.
  6. [Any Precondition Failed]

    • Log specific reason for abort.
    • Increment invoicesFailedGeneration.

Log Report

Process Log


Log CSV Export

A scheduled function (pubsub_generateIppInvoicingLogsCSV) generates CSV exports of the import logs.

Trigger

  • Pub/Sub Topic: generateIppInvoicingLogsCSV

Default Behavior

  • Exports today's logs by default.
  • Can be configured to export logs for a specific date.

Output Location

exports/ippInvoicing/logs/{year}/{monthName}/{day}/{ipp_invoicing_logs_{year}-{month}-{day}.csv}

Content

  • Includes all log entries from the import process.
  • Excludes the end-of-log-entry document.

Process Log

  • Creates a process log entry with type KWIKFIT_IPP_INVOICE.
  • Contains execution statistics.

Enquiry Progression

When Preconditions are satisfied

  1. Progress to Completed:

    • Updates enquiry status to "Completed"
    • Adds event log entry with user "IPP"
  2. Generate Invoice Data:

    • Retrieves prefilled invoice data from the enquiry
    • Merges IPP invoice details:
      • taxPointDate → from TAX_DATE (formatted as "dd MMM yyyy")
      • invoiceNumber → from INVOICE_NO
      • invoiceSavedDate → current timestamp
      • calculatedGrandTotal → from prefilled data
  3. Save Invoice Data:

    • Saves invoice data to: accounts/{accountId}/serviceUnits/{serviceUnitId}/enquiries/{enquiryId}/invoices/invoice
  4. Create Invoice and Progress to Invoiced:

    • Generates an invoice.
    • Adds event log entries: "Enquiry Completed by IPP" and "Enquiry Invoiced by IPP".
    • Progresses the enquiry status from "Completed" to "Invoiced".
    • Updates the enquiry documents in both the supplier and lease company systems.
    • Sets the invoiceGenerated flag to true.
    • Saves the enquiry to the billing system.

Note: Invoice PDF generation and export record creation are automatically handled as part of the invoicing process.

Event Log

Authored By: Vani.B on Jan 10, 2026